#coding=cp936
import os
import shutil
import sys

def view_all_exts(dirname):
    exts=['.dcu','.~pas','.~dfm','.bat','.ddp','.~ddp','.~dfm','.~dpr','~bpg','.exe']
    
    if os.path.isfile(dirname):
        #print dirname
        #print dirname[-4:]
        exta=os.path.splitext(dirname)[1]
        name=os.path.splitext(dirname)[0]
        print(exta)
        print('maybe:'+dirname[-10:])
        if dirname[-10:].lower() == 'kzhygl.exe':
            print('truely:'+dirname.lower())
            os.remove(dirname)
        #if exta.lower() in exts:
            #print exta.lower()
            #print(dirname.lower())
            #os.remove(dirname)
            
        
    elif os.path.isdir(dirname):
        for item in os.listdir(dirname):
            itemsrc = os.path.join(dirname,item)
            view_all_exts(itemsrc)
         
if __name__ == "__main__":
    dirname = r'F:\GITHUB\KzWork\KZHYGL\Client\Bin\KZHYGL'
    #filname = r'E:\quickdisk\Delphi\Delphi_Pack\Class_KzUtils.pas'
    #dirname  =  os.getcwd()
    print ('current dirname:'+dirname)
    
    truepassword = r'go'
    temppassword = input('enter password:')
    #print temppassword
    if truepassword != temppassword :
        sys.exit()
    print (r'successful')
    view_all_exts(dirname)  
